package com.greenleaf.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.greenleaf.entity.PdtClass;
import com.greenleaf.entity.PdtImgs;
import com.greenleaf.entity.SearchCon;
import com.greenleaf.serviceImpl.PdtImgServiceImpl;

@Controller
@RequestMapping("/pdtImg")
public class PdtImgController {
		@Resource
		private PdtImgServiceImpl pdtImgService;
		
		@RequestMapping("/getPdtImgs")
		@ResponseBody
		//http://localhost:8080/Greenleaf/pdtImg/getPdtImgs
		public Object getStock(SearchCon searchCon) {
			List<PdtImgs> user = pdtImgService.getAllPdtImg(searchCon);
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("code", "0");
			map.put("msg", "0");
			map.put("count",pdtImgService.getTotalPdtImg(searchCon));
			map.put("data", user);
			return map;
		}
		
		@RequestMapping("/add")
		@ResponseBody
		//http://localhost:8080/Greenleaf/pdtImg/add
		public Object addPdtClass(PdtImgs pdtImg) {
			return pdtImgService.addPdtImg(pdtImg);
		}
		@RequestMapping("/update")
		@ResponseBody
		//http://localhost:8080/Greenleaf/pdtImg/update
		public Object updateProduct(PdtImgs pdtImg) {
			int r = pdtImgService.updatePdtImg(pdtImg);
			return r!=0?true:false;
		}
		
		@RequestMapping("/del")
		@ResponseBody
		//http://localhost:8080/Greenleaf/pdtImg/del
		public Object delProduct(int pdtImg) {
			int r = pdtImgService.delPdtImg(pdtImg);
			return r!=0?true:false;
		}

}